import { Typography, Layout, Space } from 'antd';
import { history } from 'umi';

const Index = () => {
  const username = localStorage.getItem('username');

  const exit = () => {
    // 在退出的时候应该要清除一些登录的信息
    localStorage.clear();
    history.push('/login');
  };

  return (
    <Layout.Header
      className="site-layout-background"
      style={{
        padding: '0 24px',
        textAlign: 'right',
        borderBottom: '1px solid #1890ff',
      }}
    >
      <Space size="large">
        <Typography.Text>欢迎你，{username}</Typography.Text>
        <Typography.Link onClick={exit}>退出</Typography.Link>
      </Space>
    </Layout.Header>
  );
};

export default Index;
